package ludowork.tools;

import java.util.ArrayList;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import ludowork.core.VisorPlugin;
import ludowork.core.Manager;
import org.reflections.Reflections;

public class PluginsManager {

    public PluginsManager() {
         Reflections reflections = new Reflections("ludowork");
         imageSources = reflections.getSubTypesOf(VisorPlugin.class);
    }
    
    public ArrayList<VisorPlugin> getImageSources(){
        ArrayList<VisorPlugin> ises= new ArrayList<VisorPlugin>();
        for (Class<? extends VisorPlugin> isclass : imageSources) {
            try {
                ises.add(isclass.newInstance());
            } catch (InstantiationException ex) {
                Manager.getManager().getLogger().addLine(ex.getMessage());
            } catch (IllegalAccessException ex) {
                Manager.getManager().getLogger().addLine(ex.getMessage());
            }
        }
        
        return ises;
    }
    
    Set<Class<? extends VisorPlugin>> imageSources;
}
